package com.songtech.server.frame.push;

import io.netty.channel.Channel;

import java.util.HashMap;
import java.util.Map;

/**
 * Create By YINN on 2018/4/8 10:01
 * Description : 管道缓存管理器
 */
public class ChannelCacheManager {

    private static Map<String, Channel> channelCache = new HashMap<>();

    public static Map<String, Channel> getChannelCache() {
        return channelCache;
    }

    public static void addChannel(String imei, Channel channel) {
        channelCache.put(imei, channel);
    }

    public static Channel getChannel(String imei) {
        return channelCache.get(imei);
    }

    public static boolean removeChannel(String imei) {
        if (channelCache.containsKey(imei)) {
            channelCache.remove(imei);
            return true;
        }
        return false;
    }

    public static void removeAll() {
        channelCache.clear();
    }

}
